Minimally invasive set of NEW_STRING changes for mmo.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 10 Nov 2013 05:24:17 +0000 (05:24 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 10 Nov 2013 05:24:17 +0000 (05:24 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4647 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/mmo.cc

index 3522ac011bca923b2fd5299dea478db376aff841..b43a31332336525507c86ce3b5975b618c826dda 100644 (file)
@@ -461,7 +461,11 @@ mmo_read_CObjWaypoint(mmo_data_t* data)
        data->name, data->visible ? "yes" : "NO", data->objid));
 
   data->data = wpt = waypt_new();
+#if NEW_STRINGS
+  wpt->shortname = QString::fromLatin1(data->name);
+#else
   wpt->shortname = xstrdup(data->name);
+#endif
 
   time = data->mtime;
   if (! time) {
@@ -521,18 +525,29 @@ mmo_read_CObjWaypoint(mmo_data_t* data)
     }
 
     if (*cend++) {
+#if NEW_STRINGS
+      wpt->notes = QString::fromLatin1(cend);
+#else
       wpt->notes = xstrdup(cend);
+#endif
     }
 
     if (wpt->HasUrlLink()) {
       DBG((sobj, "url = \"%s\"\n", wpt->url));
     }
   } else if (*str) {
+#if NEW_STRINGS
+    wpt->notes = QString::fromLatin1(str);
+#else
     wpt->notes = xstrdup(str);
+#endif
   }
   xfree(str);
-
+#if NEW_STRINGS
+  if (!wpt->notes.isEmpty()) {
+#else
   if (wpt->notes) {
+#endif
     DBG((sobj, "notes = \"%s\"\n", wpt->notes));
   }
 
@@ -979,16 +994,24 @@ mmo_finalize_rtept_cb(const waypoint* wptref)
 
     wpt->latitude = wpt2->latitude;
     wpt->longitude = wpt2->longitude;
-
+#if NEW_STRINGS
+    wpt->shortname = (wpt2->shortname);
+#else
     xfree(wpt->shortname);
     wpt->shortname = xstrdup(wpt2->shortname);
+#endif
 
+#if NEW_STRINGS
+      wpt->description = (wpt2->description);
+      wpt->notes = (wpt2->notes);
+#else
     if (wpt2->description) {
       wpt->description = xstrdup(wpt2->description);
     }
     if (wpt2->notes) {
       wpt->notes = xstrdup(wpt2->notes);
     }
+#endif
     if (wpt2->HasUrlLink()) {
       UrlLink l = wpt2->GetUrlLink();
       wpt->notes = xstrdup(l.url_.toUtf8().data());
@@ -1237,7 +1260,8 @@ mmo_write_obj_head(const char* sobj, const char* name, const time_t ctime,
 static void
 mmo_write_wpt_cb(const waypoint* wpt)
 {
-  char* str, *cx;
+  char* str; 
+  String cx;
   int objid;
   time_t time;
   int icon = 0;
@@ -1263,9 +1287,13 @@ mmo_write_wpt_cb(const waypoint* wpt)
   }
 
   DBG(("write", "waypoint \"%s\"\n", wpt->shortname ? wpt->shortname : "Mark"));
-
+#if NEW_STRINGS
+  objid = mmo_write_obj_head("CObjWaypoint",
+                             wpt->shortname.isEmpty() ? "Mark" : CSTRc(wpt->shortname), time, obj_type_wpt);
+#else
   objid = mmo_write_obj_head("CObjWaypoint",
                              (wpt->shortname && *wpt->shortname) ? CSTRc(wpt->shortname) : "Mark", time, obj_type_wpt);
+#endif
   data = mmo_register_object(objid, wpt, wptdata);
   data->refct = 1;
   mmo_write_category("CCategory", (mmo_datatype == rtedata) ? "Waypoints" : "Marks");
@@ -1304,7 +1332,7 @@ mmo_write_wpt_cb(const waypoint* wpt)
       tmp.is_html = 1;
       cx = kml = strip_html(&tmp);
     }
-    str = xstrappend(str, cx);
+    str = xstrappend(str, CSTRc(cx));
     if (kml) {
       xfree(kml);
     }
@@ -1360,9 +1388,13 @@ mmo_write_rte_head_cb(const route_head* rte)
   if (time == 0x7FFFFFFF) {
     time = gpsbabel_time;
   }
-
+#if NEW_STRINGS
+  objid = mmo_write_obj_head("CObjRoute",
+                             rte->rte_name.isEmpty() ? "Route" : CSTRc(rte->rte_name), time, obj_type_rte);
+#else
   objid = mmo_write_obj_head("CObjRoute",
                              (rte->rte_name && *rte->rte_name) ? CSTRc(rte->rte_name) : "Route", time, obj_type_rte);
+#endif
   mmo_register_object(objid, rte, rtedata);
   mmo_write_category("CCategory", "Route");
   gbfputc(0, fout); /* unknown */
@@ -1411,9 +1443,13 @@ mmo_write_trk_head_cb(const route_head* trk)
   if (trk->rte_waypt_ct <= 0) {
     return;
   }
-
+#if NEW_STRINGS
+  objid = mmo_write_obj_head("CObjTrack",
+                             trk->rte_name.isEmpty() ? "Track" : CSTRc(trk->rte_name), gpsbabel_time, obj_type_trk);
+#else
   objid = mmo_write_obj_head("CObjTrack",
                              (trk->rte_name && *trk->rte_name) ? CSTRc(trk->rte_name) : "Track", gpsbabel_time, obj_type_trk);
+#endif
   mmo_write_category("CCategory", "Track");
   gbfputuint16(trk->rte_waypt_ct, fout);